<script>
	export default {
		globalData: {
			// base_url: "http://127.0.0.1:8081", 
			// base_url: "http://10.0.2.2:8081", 
			// base_url: "http://10.10.10.201:4523/m1/2909071-0-default",
			// base_url: "https://api.zongdago.top/apiV1",
			base_url: "https://api.zongdago.com/apiV1",
			zfapi_url: "https://api.zongdago.com/zfapi",
			local_user: {},
			access_token: "",
			username:"",
			nickname:"",
			login_checked: false,
			tmp: {
				switchTab_ID: 1
			},
			refreshLoginStatus: async function() {
				let data = await uni.request({
					url:this.base_url + "/get/user_info",
					header: { "token": this.access_token },
					// success(data) {
					// 	data = data.data
					// 	getApp().globalData.local_user.username = data.username
					// 	getApp().globalData.local_user.nickname = data.nickname
					// 	getApp().globalData.local_user.avatar_url = data.avatar_url
					// 	getApp().globalData.local_user.id = data.id
					// 	getApp().globalData.local_user.login_checked = true
					// }
				})
				data = data.data
				getApp().globalData.local_user.username = data.username
				getApp().globalData.local_user.nickname = data.nickname
				getApp().globalData.local_user.avatar_url = data.avatar_url
				getApp().globalData.local_user.id = data.id
				getApp().globalData.local_user.login_checked = true
				return 1
			}
		},
		onLaunch: function() {
			// #ifdef MP-WEIXIN
			uni.login({
				provider: "weixin",
				onlyAuthorize: true,
				success: (event) => {
					let code = event.code
					uni.request({
						url: getApp().globalData.base_url + "/login_with_wx",
						method: "POST",
						data: {"code": code},
					}).then(data => {
						data = data.data
						getApp().globalData.access_token = data.token
					})
				}
			})
			// #endif
			console.log('App Launch')
			this.globalData.access_token = uni.getStorageSync("access_token")
			console.log(this.globalData.access_token)
		},
		onShow: function() {
			console.log('App Show')
		},
		onHide: function() {
			console.log('App Hide')
		},
		onPageNotFound() {
			uni.navigateTo({
				url:"/pages/404/404"
			})
		},
	}
</script>

<style lang="scss">
	@import "@/uni_modules/uview-ui/index.scss";
	/*每个页面公共css */
</style>
